package com.xk.demo.organ.control;

import com.xk.demo.common.control.BaseController;
import com.xk.demo.mybatis.entity.PtOrganEntity;
import com.xk.demo.mybatis.flexigrid.PadingRstType;
import com.xk.demo.mybatis.flexigrid.PagingBean;
import com.xk.demo.organ.entity.OrganSearchEntity;
import com.xk.demo.organ.service.OrganService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.security.access.annotation.Secured;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author qinmiao
 * @className OrganController
 * @description TODO
 * @date 2022.05.18 21:26
 */
@Controller
@RequestMapping("/organ")
public class OrganController extends BaseController {
    private Logger logger =  LogManager.getLogger(this.getClass().getName());
    @Resource
    private OrganService organService;
    @Secured("ROLE_gqgy_data_organ")
    @RequestMapping("/organPage")
    public String organPage(){
        return "/organ/organPage";
    }
    @RequestMapping("/getOrganInfoListByPage")
    @ResponseBody
    public PadingRstType<PtOrganEntity> getOrganInfoListByPage(OrganSearchEntity search, PagingBean paging){
        logger.info(search);
        PadingRstType<PtOrganEntity> ptOrganEntityPadingRstType = organService.getOrganInfoListByPage(search,paging);
        return ptOrganEntityPadingRstType;
    }
    @RequestMapping("/bindOrganStructure")
    @ResponseBody
    public void bindOrganStructure(@RequestParam("organUuid")String organUuid, @RequestParam("parentUuid")String parentUuid){
        organService.bindOrganStructure(organUuid,parentUuid);
    }
    @RequestMapping("/unbindOrganStructure")
    @ResponseBody
    public void unbindOrganStructure(@RequestParam("organUuid")String organUuid, @RequestParam("parentUuid")String parentUuid){
        organService.unbindOrganStructure(organUuid,parentUuid);
    }
}
